﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BtLibs
{
    public static class ByteUtility
    {
        public static int IndexOf(byte[] buffer, byte[] pattern)
        {
            int index = -1;
            while ((index = Array.IndexOf(buffer, pattern[0], index + 1)) > 0)
            {
                bool match = true;
                for (int i = 1; i < pattern.Length; i++)
                {
                    if (buffer[index + i] != pattern[i])
                    {
                        match = false;
                        break;
                    }
                }
                if (match) { return index; }
            }
            return -1;
        }
    }
}
